
if (Meteor.isServer) {
  //Meteor.startup(function () {  // Global API configuration

    var Api = new Restivus({
      useDefaultAuth: true,
      prettyJson: true,
      enableCors: true
    });
    Api.addRoute('search', {authRequired: false}, {
      post : {
        action: function () {
          var users = Meteor.users.find({roles: { $in: ['driver']}, 'status.online': true}, {fields: {username: 1, location: 1}});
          //console.log('login action');
          if (users) {
            return {
              statusCode: 200,
              body: {users: JSON.stringify( users.fetch() )}
            };
          } else {
            return {         
              statusCode: 400,
              body: {status: "fail", message: "没找到这个用户, 拒绝登陆"}
            };
          }
        }
      }
    });
//  })
}